package framework.elements;

import org.openqa.selenium.By;

/**
 * Menu item class
 */
public class MenuItem extends BaseElement {

    /** Menu item separator (used for logging). */
    protected static final String DELIMITER = " -> ";
    protected MenuItem() {
    }

    public MenuItem(final By locator, final String[] names) {
        super(locator, getName(names));
    }

    protected String getElementType() {
        return "Menu Item";
    }

    /**
     * Make a full path to the menu (for logging).
     *
     * @param names
     *              An array of menu items for complex menu
     * @return full path of the menu item
     */
    protected static String getName(final String[] names) {
        StringBuffer result = new StringBuffer(names[0]);
        for (int i = 1; i < names.length; i++) {
            result.append(DELIMITER);
            result.append(names[i]);
        }
        return result.toString();
    }
}
